import { Config } from "../../Config"
import { BigState } from "../core/Big"
import { Player } from "../core/Player"
import Utils from "../GameUtils"
import { BaseHandler } from "./BaseHandler"

export class 幽灵Handler extends BaseHandler{

    /**
     * 游荡，其实和移动是一个意思，撞死后给对面加一个怯战状态，不管对面有没有护盾
     * @param data 
     * @param player 
     * @returns 
     */
    move(data:any,player:Player) {
        this.handlerMgr.spendAction(player,Config.COST_幽灵_MOVE)
        let startPoint = this.gameMgr.map_point.get(data.start)
        let endPoint = this.gameMgr.map_point.get(data.end)
        let big_start = startPoint.big
        big_start.actionOnce()
        let big_end = endPoint.big
        if(big_end != null) {
            big_end.deleteState(BigState.HIDE)
            big_end.addState(BigState.FEAR)
            big_start.die(player,endPoint.id)
            return
        }
        startPoint.big = null
        endPoint.big = big_start
        big_start.point = endPoint
        this.gameMgr.sendBroadcast(Utils.getObj("幽灵_游荡",{"start":data.start,"end":data.end}))
    }
}